define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'admin/activityPrize/index?activity_id=' + window.activityId,
        add_url: 'admin/activityPrize/add?activity_id=' + window.activityId,
        edit_url: 'admin/activityPrize/edit?activity_id=' + window.activityId,
        delete_url: 'admin/activityPrize/delete?activity_id=' + window.activityId,
        export_url: 'admin/activityPrize/export?activity_id=' + window.activityId,
        modify_url: 'admin/activityPrize/modify?activity_id=' + window.activityId,
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh', 'add'],
                cols: [[
                    {field: 'image', title: '奖品图片', search: false, templet: ea.table.image},
                    {field: 'name', title: '奖品名称', search: false},
                    {field: 'odds', title: '中奖概率', search: false, templet: function (d) {
                        return d.odds + '%';
                    }},
                    {field: 'actual_odds', title: '真实中奖率', search: false, templet: function (d) {
                        return d.actual_odds + '%';
                    }},
                    {field: 'stock', title: '库存数量', search: false},
                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});